const Mock = require('mockjs')
const randomOne = [
  [1, 2, 3, 4],
  [7, 5, 8, 3],
  [2, 5, 7, 4],
  [3, 6, 5, 7],
  [2, 5, 3, 7],
  [6, 7, 4, 9]
]
const randomTWo = [
  [150, 120, 170, 140, 500, 160, 110],
  [5, 12, 11, 14, 25, 16, 10],
  [10, 10, 30, 12, 15, 3, 7],
  [170, 140, 500, 5, 12, 11, 1],
  [15, 3, 7, 170, 140, 500, 160],
  [10, 30, 12, 15, 11, 14, 25]
]
const randomThree = [
  [150, 120, 170, 140, 500, 160, 110],
  [120, 170, 220, 260, 222, 300, 450],
  [300, 288, 255, 188, 222, 180, 199],
  [244, 233, 255, 155, 188, 299, 555],
  [155, 555, 444, 333, 433, 522, 388],
  [288, 677, 557, 664, 388, 465, 385]
]
const randomFour = [
  [182, 234, 290, 104, 131, 230],
  [193, 234, 310, 121, 134, 281],
  [195, 175, 431, 125, 123, 254],
  [123, 234, 123, 89, 126, 122],
  [183, 234, 131, 98, 124, 123],
  [123, 253, 127, 176, 125, 66],
  [134, 247, 431, 287, 135, 154]

]
const randomSix = [
  [50, 90, 91, 45, 25, 16, 10],
  [70, 40, 30, 65, 45, 36, 77],
  [95, 70, 70, 85, 87, 85, 41],
  [100, 89, 76, 99, 76, 65, 95]
]
Mock.Random.extend({
  oneInfo: function(date) {
    return this.pick(randomOne)
  },
  twoInfo: function(date) {
    return this.pick(randomTWo)
  },
  threeInfo: function(date) {
    return this.pick(randomThree)
  },
  fourInfo: function(date) {
    return this.pick(randomFour)
  },
  sixInfo: function(date) {
    return this.pick(randomSix)
  }
})
Mock.mock('@ONEINFO')
Mock.mock('@TWOINFO')
Mock.mock('@THREEINFO')
Mock.mock('@FOURINFO')
Mock.mock('@SIXINFO')
const listData = Mock.mock({
  list: {
    admin: '@integer(3,12)',
    teacher: '@integer(10,20)',
    subject: '@integer(1,10)',
    class: '@integer(1,10)'
  },
  oneInfo: {
    A: '@ONEINFO',
    B: '@ONEINFO',
    C: '@ONEINFO'
  },
  twoInfo: {
    Adidas: '@TWOINFO',
    Nike: '@TWOINFO',
    beijing: '@TWOINFO'
  },
  threeInfo: {
    Email: '@THREEINFO',
    Union: '@THREEINFO',
    Video: '@THREEINFO',
    Direct: '@THREEINFO',
    Search: '@THREEINFO'
  },
  fourInfo: {
    top: '@FOURINFO',
    buttom: '@FOURINFO'
  },
  sixInfo: {
    new: '@SIXINFO',
    all: '@THREEINFO'
  }

})
// console.log(listData)
module.exports = [
  {
    url: '/mock/content/dashindex',
    type: 'get',
    response: (config) => {
      // console.log(config)
      if (config.query.title) {
        // console.log(listData.list)
        const res = listData.list.filter((item) => item.title === config.query.title)
        console.log(res)
        console.log()
        if (res.length) {
          return {
            code: 0, message: '', data: {
              list: res,
              total: res.length
            }}
        } else {
          return { code: 9997, message: '数据不存在', data: res }
        }
      } else {
        const list = listData.list
        const oneInfo = listData.oneInfo
        const twoInfo = listData.twoInfo
        const threeInfo = listData.threeInfo
        const fourInfo = listData.fourInfo
        const sixInfo = listData.sixInfo
        // console.log(total)
        return {
          code: 0,
          message: 'ok',
          data: {
            list,
            oneInfo,
            twoInfo,
            threeInfo,
            fourInfo,
            sixInfo
          }
        }
      }
    }

  }
]
